/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package org.aroundme.unittests;

import java.util.ArrayList;
import java.util.Collections;

import junit.framework.TestCase;

import org.aroundme.model.DateManager;
import org.aroundme.model.Place;
import org.aroundme.utility.PlaceDateComparator;

public class PlaceDateComparatorTest extends TestCase {
	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	public void testSortList(){
		ArrayList<Place> list = new ArrayList<Place>();
		Place p = new Place();
		p.setId(1);
		Place p2 = new Place();
		p2.setId(2);
		Place p3 = new Place();
		p3.setId(3);
		p.setCreationDate(new DateManager().createSimpleDate("15.05.1985"));
		p2.setCreationDate(new DateManager().createSimpleDate("05.03.1985"));
		p3.setCreationDate(new DateManager().createSimpleDate("10.08.1957"));
		list.add(p);
		list.add(p2);
		list.add(p3);
		
		Collections.sort(list, new PlaceDateComparator());
		
		assertEquals("1st should be p3", p3.getId(), list.get(0).getId());
	}

}
